const mongoose = require('mongoose')
const Schema = mongoose.Schema
const defaultSchema = require('./defaultSchema')

module.exports = function(db){
  let schemaList = Object.assign({}, defaultSchema, this.options.db.schema)

  for(var i in schemaList)
    schemaList[i] = function() {
      const schema = new Schema(schemaList[i])
      return db.model(i, schema, i)
    }()

  return schemaList
}
